home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_11 / phillip2 / main422.c < prev    next >
C/C++ Source or Header  |  1993-04-10  |  3KB  |  116 lines

  1.  
  2.  
  3.        /***********************************************
  4.        *
  5.        *       file d:\cips\main422.c
  6.        *
  7.        *       Functions: This file contains
  8.        *          main
  9.        *
  10.        *       Purpose:
  11.        *          This file contains the main calling
  12.        *          routine for a program which shrinks
  13.        *          a 400x400 image down to a 200x200
  14.        *          image.
  15.        *
  16.        *       External Calls:
  17.        *          gin.c - get_image_name
  18.        *          numcvrt.c - get_integer
  19.        *                      int_convert
  20.        *          tiff.c - read_tiff_header
  21.        *          scale.c - shrink_image_array
  22.        *
  23.        *       Modifications:
  24.        *          18 April 1992 - created
  25.        *
  26.        *************************************************/
  27.  
  28. #include "cips.h"
  29.  
  30.  
  31.  
  32. short the_image[ROWS][COLS];
  33. short out_image[ROWS][COLS];
  34.  
  35. main(argc, argv)
  36.    int argc;
  37.    char *argv[];
  38. {
  39.  
  40.    char     method[80], name[80], name2[80];
  41.    int      count, length, width;
  42.    struct   tiff_header_struct image_header;
  43.  
  44.    my_clear_text_screen();
  45.  
  46.        /***********************************************
  47.        *
  48.        *       Interpret the command line parameters.
  49.        *
  50.        ************************************************/
  51.  
  52.    if(argc < 4 || argc > 4){
  53.     printf(
  54.      "\n"
  55.      "\n usage: main422 in-file out-file method"
  56.      "\n        where the in-file should be 400x400"
  57.      "\n        and the out-file will be 200x200"
  58.      "\n        method can be Average, Median, Corner"
  59.      "\n");
  60.     exit(0);
  61.    }
  62.  
  63.    strcpy(name,   argv[1]);
  64.    strcpy(name2,  argv[2]);
  65.    strcpy(method, argv[3]);
  66.  
  67.    if(method[0] != 'A' &&
  68.       method[0] != 'a' &&
  69.       method[0] != 'M' &&
  70.       method[0] != 'm' &&
  71.       method[0] != 'C' &&
  72.       method[0] != 'c'){
  73.       printf("\nERROR: Did not enter a valid method"
  74.              "\n       The valid methods are:"
  75.              "\n       Average, Median, Corner");
  76.       exit(-2);
  77.    }
  78.  
  79.    create_file_if_needed(name, name2, out_image);
  80.  
  81.        /***********************************************
  82.        *
  83.        *   Read and shrink each 200x200 area of the  
  84.        *   input image and write them to the output  
  85.        *   image.                        
  86.        *
  87.        ************************************************/
  88.  
  89.    count = 1;
  90.  
  91.    printf(" %d", count++);
  92.    shrink_image_array(name, name2, the_image,
  93.                       out_image, 1, 1, 101, 101,
  94.                       1, 1, 101, 101,
  95.                       2, method);
  96.  
  97.    printf(" %d", count++);
  98.    shrink_image_array(name, name2, the_image,
  99.                       out_image, 1, 201, 101, 301,
  100.                       1, 101, 101, 201,
  101.                       2, method);
  102.  
  103.    printf(" %d", count++);
  104.    shrink_image_array(name, name2, the_image,
  105.                       out_image, 201, 1, 301, 101,
  106.                       101, 1, 201, 101, 
  107.                       2, method);
  108.  
  109.    printf(" %d", count++);
  110.    shrink_image_array(name, name2, the_image,
  111.                       out_image, 201, 201, 301, 301, 
  112.                       101, 101, 201, 201, 
  113.                       2, method);
  114.  
  115. }  /* ends main  */
  116.